<template>
    <div class="ueditor-container">
        <UE :ref="messageType"></UE>
        <el-button class="ueditor-submit" type="primary" @click="publish">发布</el-button>
    </div>
</template>
<script>
    import UE from '@components/UE.vue'; //调用编辑器

    import Api from '@utils/api';
    import { mapGetters } from 'vuex';

    export default {
        name: 'teacherEditor',
        props: {
            messageType: String
        },
        data () {
            return {
                content: '',
                editorOption: {}
            }
        },
        components: {
            "UE": UE
        },
        methods: {
            getContent () {
                return this.$refs[this.messageType].content;
            },
            publish () {
                let param = {
                    course_id: this.getCurrentCourseId,
                    course_teacher: this.getUserId
                };

                param[this.messageType] = this.getContent();

                Api({
                    method: 'post',
                    url: '/updateCourse',
                    data: param
                }).then(() => {
                    this.$notify({
                        type: 'success',
                        title: '发布成功！'
                    });
                })
            }
        },
        computed: {
            ...mapGetters([
                'getUserId',
                'getCurrentCourseId'
            ]),
            // editor() {
            //     return this.$refs.myTextEditor.quillEditor
            // }
        }
    }
</script>
<style type="text/scss" lang="scss">
    .ueditor-container {
        .ql-editor {
            min-height: 400px;
            height: 400px;
        }
        .ueditor-submit {
            margin-top: 20px;
        }
    }
</style>